﻿{include file="public/header"}
<link rel="stylesheet" type="text/css" href="{$Think.DOMAIN_SRC}/lib/chat/css/amaze.css" />
<link rel="stylesheet" type="text/css" href="{$Think.DOMAIN_SRC}/lib/chat/css/app.css" />
<title>益鸟维修后台管理系统</title>
</head>

<body>
<header class="navbar-wrapper">
    <div class="navbar navbar-fixed-top" id='app'>
        <div class="container-fluid cl" style="min-height:50px"><a class="logo navbar-logo f-l mr-10 hidden-xs"
                                                                   href="{:url('index/index/index')}">益鸟维修后台管理系统</a>
            <span class="logo navbar-slogan f-l mr-10 hidden-xs">v1.1</span>
            <div class="ch-nav-toggle" style="left:20px;top: 8px">
                <i id="chat223" onClick='chat22()' style="height:35px;height:35px;line-height:35px;border-radius: 5px;text-align: center"><span class="glyphicon glyphicon-volume-up" aria-hidden="true"></span></i>
            </div>
            <div class="ch-nav-toggle">
                <i class="i-1"></i>
                <i class="i-2"></i>
                <i class="i-3"></i>
            </div>
            <nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
                <ul class="cl">
                    <li class="dropDown dropDown_hover">
                        <a href="#" class="dropDown_A">{$username}<i
                                class="Hui-iconfont">&#xe6d5;</i></a>

                        <ul class="dropDown-menu menu radius box-shadow">
                            <li><a href="{:Url('index/login/logout')}">安全退出</a></li>
                            <li><a href="javascript:;" class="edit_password">修改资料</a></li>
                        </ul>
                    </li>
                    <li style="padding: 5px">
                        <img src="{$loge}" width="20">
                    </li>
                    <li id="Hui-skin" class="dropDown right dropDown_hover">
                        <a href="javascript:;" class="dropDown_A" title="换肤">
                            <i class="Hui-iconfont" style="font-size:18px">&#xe62a;</i>
                        </a>
                        <ul class="dropDown-menu menu radius box-shadow">
                            <li><a href="javascript:;" data-val="default" title="默认（黑色）">默认（黑色）</a></li>
                            <li><a href="javascript:;" data-val="blue" title="蓝色">蓝色</a></li>
                            <li><a href="javascript:;" data-val="green" title="绿色">绿色</a></li>
                            <li><a href="javascript:;" data-val="red" title="红色">红色</a></li>
                            <li><a href="javascript:;" data-val="yellow" title="黄色">黄色</a></li>
                            <li><a href="javascript:;" data-val="orange" title="橙色">橙色</a></li>
                        </ul>
                    </li>
                    <li>
                        <button onClick='chat22()' type="button" class="btn btn-default" id="chat22"><span
                                class="glyphicon glyphicon-volume-up" aria-hidden="true"></span></button>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</header>
<div class="ch-aside">
    <aside class="Hui-aside">
        <div class="menu_dropdown bk_2">
            {$v}
        </div>
    </aside>
</div>

<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a>
</div>
<section class="Hui-article-box">
    <div id="Hui-tabNav" class="Hui-tabNav hidden-xs">
        <div class="Hui-tabNav-wp">
            <ul id="min_title_list" class="acrossTab cl">
                <li class="active">
                    <span title="我的桌面" data-href="welcome.html">我的桌面</span>
                    <em></em></li>
            </ul>
        </div>
        <div class="Hui-tabNav-more btn-group"><a id="js-tabNav-prev" class="btn radius btn-default size-S"
                                                  href="javascript:;"><i class="Hui-iconfont">&#xe6d4;</i></a><a id="js-tabNav-next"
                                                                                                                 class="btn radius btn-default size-S" href="javascript:;"><i class="Hui-iconfont">&#xe6d7;</i></a>
        </div>
    </div>
    <div id="iframe_box" class="Hui-article">
        <div class="show_iframe">
            <div style="display:none" class="loading"></div>
            <iframe scrolling="yes" frameborder="0" src="{:url('index/index/welcome')}"></iframe>
        </div>
    </div>
</section>

<div class="contextMenu" id="Huiadminmenu">
    <ul>
        <li id="closethis">关闭当前</li>
        <li id="closeall">关闭全部</li>
    </ul>
</div>
{include file="public/footer"}
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.bootcss.com/blueimp-md5/2.7.0/js/md5.js"></script>
<script type="text/javascript" src="{$Think.DOMAIN_SRC}/lib/chat/js/jmessage-sdk-web.2.6.0.min.js"></script>
<script type="text/javascript" src="{$Think.DOMAIN_SRC}/lib/chat/js/amazeui.min.js"></script>
<script>
    function chat22() {
        $('#chat22').removeClass('shanqilai');
        $('#chat223').removeClass('shanqilai');
        var src = '<?php echo DOMAIN_SRC ?>' + "chat/index.html"
        var json = {
            username: 'mmm'+"<?php echo session('admin_id')?>",
            password: 'asdfghjkl123456',
            media_id: "<?php echo session('logo')?>"
        }
        localStorage.setItem('json', JSON.stringify(json))
        window.open(src);
    }
   	 $(document).on("click", ".edit_password", function () {
        var src = "{:Url('index/user/edit_password')}";
        layer.open({
            type: 2,
            area: ['800px', '500px'],
            fix: false,
            maxmin: true,
            shade: 0.4,
            title: '修改密码',
            content: src
        });
    });
    $(function () {
        //----------------------------header-----------------------
        $(".ch-aside").css("height", $(window).height() - 50 + "px")
        $(".ch-nav-toggle").on("click", function () {
            console.log($(".Hui-aside").height())
            if ($(".ch-nav-toggle").hasClass("active")) {
                $(".ch-nav-toggle").removeClass("active");
                $(".ch-aside").css("top", "-100%");
            } else {
                $(".ch-nav-toggle").addClass("active");
                $(".ch-aside").css("top", "50px");
            }
        })
        $(".menu_dropdown dl dd ul li a").on("click", function () {
            $(".ch-nav-toggle").removeClass("active");
            $(".ch-aside").css("top", "-100%");
        })
    })
</script>
<script>
    window.JIM = new JMessage({
        debug: true
    });
    var app = new Vue({
        el: '#app',
        data: {
            types: true,
            friend_list: [],
            aa: "",
            timestamp2: "",
            changeSelectStyle: 0,
            txtval: "",
            from_username: "",
            messages: [],
            messages2: [],
            nickname: "",
            heightM: ""
        },
        mounted() {
            // 初始化
            this.timestamp2 = new Date().getTime()
            var signature = "appkey=93f21e7e6307ceca0ee63ca6&timestamp=" + this.timestamp2 + "&random_str=022cd9fd995849b58b3ef0e943421ed9&key=906af07d6b10bff936e0627a";
            this.aa = md5(signature)
            var lett = this;
            lett.IsPC()
            lett.init()
        },
        updated() {
            this.$nextTick(function () {
                var div = document.getElementById('dialogue_box');
                div.scrollTop = div.scrollHeight;
            })
        },
        methods: {
            IsPC() {
                var userAgentInfo = navigator.userAgent;
                var Agents = ["Android", "iPhone",
                    "SymbianOS", "Windows Phone",
                    "iPad", "iPod"];
                var flag = true;
                for (var v = 0; v < Agents.length; v++) {
                    if (userAgentInfo.indexOf(Agents[v]) > 0) {
                        flag = false;
                        break;
                    }
                }
                this.types = flag;
            },
            // 初始化
            init() {
                let that = this
                JIM.init({
                    "appkey": "93f21e7e6307ceca0ee63ca6",
                    "random_str": "022cd9fd995849b58b3ef0e943421ed9",
                    "signature": this.aa,
                    "timestamp": this.timestamp2,
                    "flag": 1
                }).onSuccess(function (data) {

                    that.appendToDashboard('success' + JSON.stringify(data));
                    that.register()
                    // that.login()
                }).onFail(function (data) {

                    that.appendToDashboard('error: ' + JSON.stringify(data));
                });
            },
            // 注册
            register() {
                let that = this
                JIM.register({
                    'username': 'mmm'+"<?php echo session('admin_id')?>",
                    'password': 'asdfghjkl123456',
                    'nickname': "<?php echo session('username')?>",
                    // 'media_id': "<?php echo session('logo')?>"
                }).onSuccess(function (data) {
                    var src="{:Url('index/order/jp')}";
                    $.ajax({
                        type: 'POST',
                        url: src,
                        dataType: 'json',
                        data:{admin_id: "<?php echo session('admin_id')?>"},
                        success: function (data) {
                            var res=JSON.parse(data);
                            if(res.code==200){
                                that.appendToDashboard(JSON.stringify(data));
                                that.login()
                            }

                        },
                        error: function (data) {
                            console.log(data.msg);
                        },
                    });
                }).onFail(function (data) {
                    that.appendToDashboard(JSON.stringify(data));
                that.login()
             })
            },
            // 登录
            login() {
                let that = this
                JIM.login({
                    'username': 'mmm'+"<?php echo session('admin_id')?>",
                    'password': 'asdfghjkl123456'
                }).onSuccess(function (data) {
                    JIM.onMsgReceive(function (data) {
                        $('#chat22').addClass('shanqilai');
                        $('#chat223').addClass('shanqilai');
                        for (let i = 0; i < data.messages.length; i++) {
                            that.messages2.push(data.messages[i])
                        }
                    });

                    JIM.onEventNotification(function (data) {
                        if (data.event_type == 5) {
                            that.acceprfrend(data.from_username, data.from_appkey)
                        }
                        // appendToDashboard('event_receive: ' + JSON.stringify(data));
                    });

                    JIM.getFriendList().onSuccess(function (data) {
                        console.log(data)
                        console.log('好友')
                        that.friend_list = data.friend_list
                        if (data.friend_list.length > 0) {
                            that.from_username = data.friend_list[0].username
                            that.nickname = data.friend_list[0].nickname
                        }
                    }).onFail(function (data) {

                        that.appendToDashboard('error: ' + JSON.stringify(data));
                    });

                    JIM.onSyncConversation(function (data) { //离线消息同步监听

                        that.messages = data

                        that.appendToDashboard('event_receive: ' + JSON.stringify(data));
                    });

                    JIM.onSyncEvent(function (data) {

                    });
                    // that.tou()
                }).onFail(function (data) {


                    that.appendToDashboard('error: ' + JSON.stringify(data));
                }).onTimeout(function (data) {

                    that.appendToDashboard('timeout: ' + JSON.stringify(data));
                });
            },
            // 同意好友添加申请
            acceprfrend(from_username, from_appkey) {
                let that = this
                JIM.acceptFriend({
                    'target_name': from_username,
                    'appkey': from_appkey
                }).onSuccess(function (data) {

                    that.appendToDashboard('success: ' + JSON.stringify(data));
                }).onFail(function (data) {

                    that.appendToDashboard('error: ' + JSON.stringify(data));
                });
            },
            // 退出
            loginOut() {
                JIM.loginOut();
            },
            // 断线监听
            Disconnect() {
                JIM.onDisconnect(function () {

                });
            },
            // 信息打印
            appendToDashboard(text) {

                console.log('信息打印')

            },
        },
    })
</script>
</body>
<style>
    .shanqilai {
        animation: myfirst 1s 0.1s infinite;
        -moz-animation: myfirst 1s 0.1s infinite;
        /* Firefox */
        -webkit-animation: myfirst 1s 0.1s infinite;
        /* Safari 和 Chrome */
        -o-animation: myfirst 1s 0.1s infinite;
        /* Opera */
        opacity: 1;
    }

    @keyframes myfirst {
        from {
            opacity: 1;
        }

        to {
            opacity: 0;
        }
    }

    @-moz-keyframes myfirst

        /* Firefox */
    {
        from {
            opacity: 1;
        }

        to {
            opacity: 0;
        }
    }

    @-webkit-keyframes myfirst

        /* Safari and Chrome */
    {
        from {
            opacity: 1;
        }

        to {
            opacity: 0;
        }
    }

    @-o-keyframes myfirst

        /* Opera */
    {
        from {
            opacity: 1;
        }

        to {
            opacity: 0;
        }
    }
</style>

</html>
